#include<iostream>
#include<string>
using namespace std;
int main() {
	int x = 0;
	for (int i = 0;; i++) {
		x += i;
		if (x > 20220514) {
			string s = to_string(x);
			string s1 = s;
			reverse(s.begin(),s.end());
			if (s1 == s) {
				cout << s << endl;
				break;
			}
		}
	}
	return 0;
}